function __EmailRegister_BuildUrl(){
    var url=__FormHelper_GetActionLink(); 
    var options=__FormHelper_GetGridObject().datagrid("options");
    var black_list = $('#combo_bl').combobox('getValue');
    var search_email=jQuery.trim(jQuery("#serch_email").searchbox("getValue"));
    if(search_email!='')
    {
     url += "&search_email="+search_email;   
    }
    if(black_list!='')
    {
     url += "&black_list="+black_list;   
    }
    // for pager
    url+="&page="+options.pageNumber+"&pageSize="+options.pageSize;
    return url;
    
}
function __AB_PDoremi_ProductManager_DelMail(table_selector){
    
    var node = __FormHelper_GetGridObject().datagrid('getSelected');
    var temp=Math.random()*9999;
    if (node){
        if (!confirm("Bạn có chắc muốn xóa email này không?"))
            return;
        // call ajax
        jQuery.post("/index.php", {
            module: 'mailinglistmodule',
            action: 'delete_email',
            ajax_action: '1',
            id: node.id,
            t: temp
        }, function(param)
        {
            __FormHelper_GetGridObject().datagrid('reload');
        }
        );
        __FormHelper_GetGridObject().datagrid('clearSelections');
    }
}
function __AB_PDoremi_EmailManager_Blacklist(table_selector,type){
    
     var node = __FormHelper_GetGridObject().datagrid('getSelected');
    if (node){
        if(type==1)
        {
            var msg = "Bạn có chắc muốn blacklist email này không?";
        }
        else
        {
            var msg = "Bạn có chắc muốn unblacklist email này không?";
        }
        if (!confirm(msg))
            return;   
        // call ajax
        jQuery.post("/index.php", {
            module: 'mailinglistmodule',
            action: 'blacklist',
            ajax_action: '1',
            id: node.id
            // t: temp
        }, function(data){
            {

                __FormHelper_GetGridObject().datagrid('reload');
            }

        });
    }
}
var form_onBeforeLoad = function(param)
{
    jQuery(this).datagrid('options').url =__EmailRegister_BuildUrl() ;
    
};
var Blacklist_Email_OnSelect = function(rowIndex, rowData){
    if (rowData.blacklist == 0){ // disabled
        jQuery("#Enable_Blacklist").show();
        jQuery("#Disable_Blacklist").hide();
    }
    else
    {
        jQuery("#Disable_Blacklist").show();
        jQuery("#Enable_Blacklist").hide();
    }
}
function _Blacklist_Set()
{
    var node = __FormHelper_GetGridObject().datagrid('getSelected');
    var temp=Math.random()*9999;
    if (node){
        jQuery.post("/index.php", {
            module: 'mailinglistmodule',
            action: 'blacklist_changestate',
            ajax_action: '1',
            id: node.id,
            t: temp
        },
        function(param)
        {
            __FormHelper_GetGridObject().datagrid('reload');
        }
        );
        __FormHelper_GetGridObject().datagrid('clearSelections');
        jQuery("#Enable_Blacklist").hide();
        jQuery("#Disable_Blacklist").hide();

    }
}
var form_mail_register_preinit = function(){
    jQuery("#Enable_Blacklist").hide();
    jQuery("#Disable_Blacklist").hide();
    $('#combo_bl').combobox({  
        mulitple: false,
        editable: false,
        panelHeight:50
    });  
}